#include<stdio.h>
#include<stdlib.h>



int main()
{
    /*数组的赋值*/
    int nums[10] = {54,12,36,47,9,21,78,90,11,29};


/*
    for (int end = 10; end > 0;end--)
    {
        for(int begin = 1; begin < end; begin++)
        {
            if (nums[begin - 1] > nums[begin])
            {
                //交换
                int temp = nums[begin - 1];
                nums[begin - 1] = nums[begin];
                nums[begin] = temp;
            }
        }
*/

     for (int end =10;end > 0; end-- )
     {
        /*已经排好序的标志*/
        int sorted = 1;
        for(int begin = 1; begin < end; begin++)
        {
            
            if (nums[begin - 1] > nums[begin])
            {
                /*交换*/
                int temp = nums[begin - 1];
                nums[begin - 1] = nums[begin];
                nums[begin] = temp;

                /*只要程序进到这个地方，就意味着数组是没有排好序的.*/
                sorted = 0;

            }


        }

           if (sorted ==1)
            {
                break;
            }


       /*
       for (int idx = 0; idx < 10; idx++)
        {
            printf("num[%d]=%d\n",idx,nums[idx]);
        }
       */
       
     } 
    for (int idx = 0; idx < 10; idx++)

        {
            printf("num[%d]=%d\n",idx,nums[idx]);
        }

     
     
     
     return 0;
}